/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package user;

import java.util.ArrayList;

/**
 *
 * @author northpole
 */
public class miscMethods {

    private Connector con;

    public miscMethods(Connector con)
    {this.con=con;}

public boolean   usernameExists(String username){
   if(con.getId(username)==-1)
       return false;
   else
       return true;
    }

public ArrayList search(String username,ArrayList interest,String date,String Name,String surname,boolean And,boolean or){
ArrayList result=null;
int i=0;
String logic=null;
String ints=null;

if(username!=null)
    i++;
if(interest!=null&&!interest.isEmpty())
{
    i++;

    ints=interest.get(0)+",";
for(int j=1;j<interest.size();j++)
    ints=ints+interest.get(j)+",";

}
//System.out.println(interest.toString());
//System.out.println(ints);
if(date!=null)
    i++;
if(Name!=null)
    i++;
if(surname!=null)
    i++;
if(And)
logic    ="AND";
else
    logic="OR";

result=con.search(username, Name, surname, date, ints,logic, i);
//result.add(ints);
return result;
}
}
